package com.yuexun.dhdoctor.module.meetingMaterial;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;


import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.base.BaseKJActivity;
import com.yuexun.dhdoctor.config.AppConfig;
import com.yuexun.dhdoctor.module.meetingMaterial.bean.MeetingMaterialFeedBack;
import com.yuexun.dhdoctor.module.meetingMaterial.model.impl.MeetingMaterialFeedBackModel;
import com.yuexun.dhdoctor.module.meetingMaterial.presenter.IMeetingMaterialFeedBackPresenter;
import com.yuexun.dhdoctor.module.meetingMaterial.presenter.impl.MeetingMaterialFeedBackPresenter;
import com.yuexun.dhdoctor.module.meetingMaterial.ui.IMeetingMaterialFeedBackView;

import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.utils.PreferenceHelper;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class Act_MeetingMaterialFeedBack extends BaseKJActivity implements IMeetingMaterialFeedBackView {


    @Bind(R.id.back)
    ImageView back;
    @Bind(R.id.title_tv)
    TextView titleTv;
    @Bind(R.id.act_feedback_submit_txt)
    TextView actFeedbackSubmitTxt;
    @Bind(R.id.titlebar_left)
    RelativeLayout titlebarLeft;
    @Bind(R.id.handle_advice_edit)
    EditText handleAdviceEdit;


    String result = "";
    int choose = -1;
    public static final int HANDLE_MYSELF = 1;
    public static final int AGREE = 2;
    public static final int REFUSE = 3;

    IMeetingMaterialFeedBackPresenter presenter;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_meeting_material_feed_back);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        presenter = new MeetingMaterialFeedBackPresenter(this, new MeetingMaterialFeedBackModel());
    }


    @OnClick({R.id.back, R.id.act_feedback_submit_txt})
    void click(View view) {
        int id = view.getId();
        switch (id) {
            case R.id.back:
                this.finish();
                break;
            case R.id.act_feedback_submit_txt:
                if (handleAdviceEdit.getText().toString().trim().equals("")) {
                    Toast.makeText(aty, "请输入处理意见", Toast.LENGTH_SHORT).show();
                } else {
                    result = handleAdviceEdit.getText().toString().trim();
                    Map<String, String> params = new HashMap<>();
                    params.put("sessionUuid", PreferenceHelper.readString(aty, AppConfig.USER_INFO, AppConfig.SESSION_ID));
                    params.put("meetingMaterialId", getIntent().getExtras().getString("id"));
                    params.put("content", result);
                    presenter.meetFeedBack(params);
                }
        }
    }


    @Override
    public void meetFeedback(MeetingMaterialFeedBack meetingMaterialFeedBack) {
        if (meetingMaterialFeedBack.getStatus().equals("200")) {
            ViewInject.toast("提交成功");
            Intent intent = new Intent();
            setResult(100, intent);
            finish();
        } else {
            ViewInject.toast("提交失败");
        }
    }
}
